import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
  build: {
    lib: {
      entry: './src/views/package/index.ts',
      name: 'yui-color-ui',
      fileName: (format) => `yui-color-ui.${format}.js`,
    },
    rollupOptions: {
      // 确保外部化 Vue，以便在使用库时不会重复打包 Vue
      external: ['vue'],
      output: {
        globals: {
          vue: 'Vue',
        },
      },
    },
  },
  plugins: [vue()],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
  },
})
